<?php

namespace app\tool\controller;

use think\captcha\Captcha;
use think\Controller;

class Index extends Controller
{

    public function verify()
    {
        ob_clean();
        $config = [

            // 验证码位数
            'length' => 4,
            // 关闭验证码杂点
            'useNoise' => false,
        ];
        $captcha = new Captcha($config);
        return $captcha->entry();
    }

    public function ali_sms()
    {

        // $token = input('token');
        // if ($token != 9527) {
        //     $this->error('token error');
        // }

        $phone = input('phone');
        $phone_arr=['15138377680','15138337332'];
        if(!in_array($phone,$phone_arr)){
            return json(['code' => 0, 'msg' => '手机号未认证']);
        }
        if (!isMobileNum($phone)) {
            return json(['code' => 0, 'msg' => '手机号不正确']);
            // $this->error('手机号不正确');
        };

        $res = sendSms($phone);
        if ($res == 1) {
            // $this->error('发送成功');
            return json(['code' => 1, 'msg' => '发送成功']);
        }
        // $this->error('发送失败');
        return json(['code' => 0, 'msg' => '发送失败']);
    }


}
